So what I was trying to do was, make the primary links menu a drop-down menu. This is not difficult, but Drupal makes it incredibly difficult, by not printing out the "sub-items", instead it saves it for when you click a primary link, then on THAT page, it puts the "expanded sub-items" in "secondary-links" div.

I don't understand why it doesn't just print it on the page, so that I can wrap a div around it or something to make it a drop down or whatever.

What's the easiest way to do this? I tried using modules like dynamic persistent menu, but not only is it not maintained but it only makes menus as blocks, which I do not want. YUI menu looks the same everywhere. Any suggestions?

Comments

matt_harrold’s picture

Go to admin/build/menu-customize/primary-links, check that the top level menu items you want to drop down are "expanded". Drupal will then behave the way you are expecting.

executex’s picture

I decided to just implement a theme() function instead of primary links theming inside the page.tpl file. Seems to be mostly working, I just got to get the styles right so that it looks good.

rightchoice2c_me’s picture

why don't you try superfish menus.

kuldip zala’s picture

pepemty’s picture

is that it isn't for primary menus, and nice primary menus isn't available for Drupal6...

Warm regards from sunny México!
:-)
Pepe

Warm regards from sunny México!
Pepe
:-)

twiik’s picture

We were depending on printing the $primary_links variable i a theme because we were overriding it programatically in a module on a per virtual site basis (100+ virtual sites) so using menu blocks instead wasn't an option.

What baffled me was the fact that $primary_links is hardcoded to be only 1 level. Like the original poster I fail to see the point of this. After trying combinations of every menu function in the drupal api I managed to find something that did the same as just printing <?php theme('links', $primary_links); ?> except it included the entire menu tree.

This was my solution:

<?php 
	# Gets the name of the menu used as primary-links
	$proper_primary_links = variable_get('menu_primary_links_source', 'primary-links');

        # Builds the menu tree
	$menu_tree_data = menu_tree_page_data($proper_primary_links);

        # Renders the menu tree
	print menu_tree_output($menu_tree_data); 
?>

This gave me a menu containing the sub menus as well which I could print wherever I wanted in my theme. Seems to be working perfectly.

I overrided the menu_tree_output() function as well as made my own theme_menu_tree() function to add some extra id's and classes to my menu and links.

I'm very happy because this was harder than it had to be. :)

Posting it here in case anybody needs the same thing.

Øyvind Strømsvik
Tech lead | Frontkom AS
https://frontkom.com/

jsp_drupal’s picture

Hello,
My problem is the same , I read your post , but unable to understand.

I am using drupal from last 2 weeks.
I want to show horizontal menu bar for end user which consist of three sublevels of child menus .
I have dynamic persistent menu module . With this I want to show my primary links in horizontal way , but instead it is showing the admin navigation in horizontal way .
I am using Bluemarine theme.

From your post what the 2 new functions are used for and where to write.
How I can use it for my purpose.
Same problem with simplemenu module.

Appreciate your help.

Thanks

executex’s picture

Ok simple and effective.

Requirements:
1) Dynamic Persistent Menu

Edit Page.tpl.php:
1) find primary links in the html, comment out what was there before...:

<?php if (!empty($primary_links)): ?>
          <div id="primary" class="clear-block">
            <?php print $DPM;
			//theme('links', $primary_links, array('class' => 'links primary-links')); 
			?>
          </div>
        <?php endif; ?>

2) Add the $DPM variable.

Edit (or create) template.php in your theme folder::

function TYPEyourTHEMEnameHERE_preprocess(&$vars){
	$params = explode(':','primary-links:0');
	$vars['DPM'] = theme('dynamic_persistent_menu', $params[0], $params[1], variable_get('dynamic_persistent_menu_sub_menu_timeout', 2000));
}

---------
It should work, sometimes cache can take some time, so it may work later on...

Lordras’s picture

HI!

I have follow your instruction step by step but now i receive a White screen of death!!! I backuped original files but return always my White screen of death.

I disable the module Dynamic Persistent Menu directed from Db but i don't resolve the problem.
Hope is temporary problem.

Regards

ollu’s picture

@ Twiik: Just what I was lookin' for!

Thanks!

Jmcpherson’s picture

I also go the white screen of death luckily for me a saved a good copy of page.tpl.php so when i got the white screen i just went to my ftp client and dragged the good version of my page.tpl.php to the corrupted one. Then i let it overwrite the the bad copy and my screen went back to normal. I still don't get how to get my primary links children to be visible. Hopefully they come up with a patch or fix real soon.